package com.hg.chapter2.event;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

//容器发布事件
@Component
public class MyPublisher {
    //其实也可以每次调用ApplicationContext来发信，但是代码不简洁

    @Autowired
    ApplicationContext applicationContext;

    public void publish(String msg) {
        applicationContext.publishEvent(new MyEvent(this, msg));
    }

}
